package Shuffle;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 利用List特性，來產生一副牌，繼承自Poke
 * @author QK
 */
class pokeTypeA extends Poke{

	private static List<String> listCards;
	private static int sufCardTime;
	
	
	/**
	 * 預設洗牌100次
	 */
	public pokeTypeA(){
		setSufCardTime(100);
		listCards = newCard();
	}
	
	/**
	 * 可設定洗牌次數
	 */
	public pokeTypeA(int timer){
		setSufCardTime(timer);
		listCards = newCard();
	}
	
	public List getListCard(){
		return listCards;
	}
	
	public static ArrayList<String> newCard() {
		List<String> cards = new ArrayList<String>();
		for (int cardOfNumer = 1; cardOfNumer < 14; cardOfNumer++) {
			for (int colorState = 0; colorState < cardOfColor.length; colorState++) {
				switch (cardOfNumer) {
				case 1:
					cards.add(cardOfColor[colorState] + "A");
					break;
				case 11:
					cards.add(cardOfColor[colorState] + "J");
					break;
				case 12:
					cards.add(cardOfColor[colorState] + "Q");
					break;
				case 13:
					cards.add(cardOfColor[colorState] + "K");
					break;
				default:
					cards.add(cardOfColor[colorState]+ String.valueOf(cardOfNumer));
				}
			}
		}
		return (ArrayList<String>) cards;
	}
	
	//Java內建洗牌方法	

	/**
	 * 呼叫洗牌程式
	 */
	public static void suffleCard(){
		for(int time = 0 ; time < getSufCardTime() ;time ++ ){
			Collections.shuffle(listCards);
		}
	}
	/**
	 * 取得洗牌次數
	 * @return
	 */
	static int getSufCardTime() {
		return sufCardTime;
	}

	/**
	 * 設定洗牌次數
	 */
	static void setSufCardTime(int sufCardTime) {
		pokeTypeA.sufCardTime = sufCardTime;
	}
	
	public static void showPokeCards(){
		Object cards[] = listCards.toArray();
		for(int i = 0 ; i < 52 ; i++){
			if(i%13==0 && i!=0){
				System.out.println();
			}
			System.out.print(cards[i].toString()+"\t");
		}
	}
}
